/* Exercise 5.44
   ejer5_44.c */
#include <stdio.h>

int mystery(int a, int b);

/* function main begins program execution */
int main(void)
{
    int x;
    int y;

    printf("Enter two integers: ");
    scanf("%d%d", &x, &y);

    printf("The result is  %d\n", mystery(x, y));

    return 0;
} /* end main */

/* Parameter b must be a positive integer
   to prevent infinite recursion */
int mystery(int a, int b)
{
    if (b == 1)
        return a;
    else
        return a + mystery(a, b - 1);
} /* end function mystery */
